package simulator.types;

public class Vector2f
{
	public float x, y;
	
	public Vector2f()
	{
		this(0f, 0f);
	}
	public Vector2f(Vector2f other)
	{
		this(other.x, other.y);
	}
	public Vector2f(float S)
	{
		this(S,S);
	}
	public Vector2f(float X, float Y)
	{
		x = X;
		y = Y;
	}
	
	public void copy(Vector2f other)
	{
		x = other.x;
		y = other.y;
	}
	
	public void set(float S)
	{
		x = S;
		y = S;
	}
	public void set(float X, float Y)
	{
		x = X;
		y = Y;
	}
	
	public final float getLength()
	{
		return (float)Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
	}
	
	public final float getDistance(Vector2f other)
	{
		return (float)Math.sqrt(Math.pow(x - other.x , 2) + Math.pow(y - other.y, 2));
	}
	
	public boolean isZero()
	{
		return (x==0 && y==0);
	}
	
	public void add(Vector2f other)
	{
		x += other.x;
		y += other.y;
	}
	
	public void add(float X, float Y)
	{
		x += X;
		y += Y;
	}
	
	public void addScaled(Vector2f other, float scale)
	{
		x += other.x * scale;
		y += other.y * scale;
	}
	
	public void addScaled(float X, float Y, float scale)
	{
		x += scale * X;
		y += scale * Y;
	}
	
	public void sub(Vector2f other)
	{
		x -= other.x;
		y -= other.y;
	}
	
	@Override
	public String toString()
	{
		return "(" + x + " , " + y + ")";
	}
}